/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelRegistration.java
 *
 * Created on 20.02.2012., 20.13.27
 */
package gui.panels;

import gui.forms.coordinator.FormCoordinator;
import java.awt.Color;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.border.LineBorder;
import logic.GetPol;
import model.avatars.FyeaAvatar;
import model.userProfiles.TrendyUserProfile;
import model.userProfiles.WhySoSeriousUserProfile;

/**
 *
 * @author Jelena
 */
public class PanelRegistration extends javax.swing.JPanel {

    /** Creates new form PanelRegistration */
    public PanelRegistration() {
        initComponents();
        setCbModel();
        PanelRegistrationCool.setEnabledAt(1, false);
        PanelRegistrationCool.setEnabledAt(2, false);
        PanelRegistrationCool.setEnabledAt(3, false);

    }

    private void setCbModel() {
        cbFirstArea.removeAllItems();
        cbSecondArea.removeAllItems();
        cbThirdArea.removeAllItems();
        List<String> areasOfInterest = FormCoordinator.getInstance().getAreasOfInterest();
        for (String string : areasOfInterest) {
            cbFirstArea.addItem(string);
            cbSecondArea.addItem(string);
            cbThirdArea.addItem(string);

        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rbgAvatar = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        rbgPol = new javax.swing.ButtonGroup();
        rbgDefaultUserProfile = new javax.swing.ButtonGroup();
        PanelRegistrationCool = new javax.swing.JTabbedPane();
        panelUserInformation = new javax.swing.JPanel();
        lblFirstName = new javax.swing.JLabel();
        tfFirstName = new javax.swing.JTextField();
        lblLastName = new javax.swing.JLabel();
        tfLastName = new javax.swing.JTextField();
        lblPol = new javax.swing.JLabel();
        rbMale = new javax.swing.JRadioButton();
        rbFemail = new javax.swing.JRadioButton();
        lblEmail = new javax.swing.JLabel();
        tfEmail = new javax.swing.JTextField();
        lblUserName = new javax.swing.JLabel();
        tfUserName = new javax.swing.JTextField();
        lblPassword = new javax.swing.JLabel();
        tfPassword = new javax.swing.JTextField();
        lblUsnError = new javax.swing.JLabel();
        btnNext1 = new javax.swing.JButton();
        panelAvatar = new javax.swing.JPanel();
        lblAvatarfyea = new javax.swing.JLabel();
        lblAvatarpface = new javax.swing.JLabel();
        lblAvatarmegusta = new javax.swing.JLabel();
        lblAvatarkiddingme = new javax.swing.JLabel();
        lblAvatartruestrory = new javax.swing.JLabel();
        lblAvatarTroll = new javax.swing.JLabel();
        rbFyea = new javax.swing.JRadioButton();
        rbmegusta = new javax.swing.JRadioButton();
        rbfkidding = new javax.swing.JRadioButton();
        rbchallenge = new javax.swing.JRadioButton();
        rbTrueStory = new javax.swing.JRadioButton();
        rbTrollFace = new javax.swing.JRadioButton();
        btnNext2 = new javax.swing.JButton();
        panelAreas = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        cbFirstArea = new javax.swing.JComboBox();
        cbSecondArea = new javax.swing.JComboBox();
        cbThirdArea = new javax.swing.JComboBox();
        btnSave = new javax.swing.JButton();
        panelDefaultUserProfile = new javax.swing.JPanel();
        rbTrendyName = new javax.swing.JRadioButton();
        rbSeriousName = new javax.swing.JRadioButton();
        lblUDTrendyImage = new javax.swing.JLabel();
        lblUDWSSImage = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listAreasOfInterestTrendy = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        listAreasOfInterestSerious = new javax.swing.JList();
        btnSaveDefaulProfileUser = new javax.swing.JButton();

        jLabel1.setText("jLabel1");

        panelUserInformation.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblFirstName.setText("Ime:"); // NOI18N

        lblLastName.setText("Prezime:"); // NOI18N

        lblPol.setText("Pol:"); // NOI18N

        rbgPol.add(rbMale);
        rbMale.setText("muški"); // NOI18N

        rbgPol.add(rbFemail);
        rbFemail.setText("ženski"); // NOI18N

        lblEmail.setText("E-mail:"); // NOI18N

        lblUserName.setText("Korisničko ime:");

        tfUserName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfUserNameFocusLost(evt);
            }
        });

        lblPassword.setText("Šifra:");

        btnNext1.setText(">>");
        btnNext1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNext1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelUserInformationLayout = new javax.swing.GroupLayout(panelUserInformation);
        panelUserInformation.setLayout(panelUserInformationLayout);
        panelUserInformationLayout.setHorizontalGroup(
            panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUserInformationLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelUserInformationLayout.createSequentialGroup()
                        .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblUserName)
                            .addComponent(lblFirstName)
                            .addComponent(lblLastName)
                            .addComponent(lblPol)
                            .addComponent(lblEmail)
                            .addComponent(lblPassword))
                        .addGap(12, 12, 12)
                        .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addGroup(panelUserInformationLayout.createSequentialGroup()
                                .addComponent(rbMale)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rbFemail))
                            .addComponent(tfLastName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addComponent(tfUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addComponent(tfFirstName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addComponent(lblUsnError, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addComponent(tfEmail, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)))
                    .addComponent(btnNext1, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        panelUserInformationLayout.setVerticalGroup(
            panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUserInformationLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFirstName)
                    .addComponent(tfFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblLastName)
                    .addComponent(tfLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblPol)
                    .addComponent(rbFemail)
                    .addComponent(rbMale))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblUserName)
                    .addComponent(tfUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblUsnError, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblPassword)
                    .addComponent(tfPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelUserInformationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEmail)
                    .addComponent(tfEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnNext1)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        PanelRegistrationCool.addTab(" Li\u010dni podaci", panelUserInformation);

        panelAvatar.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblAvatarfyea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/pictures/fyea.png"))); // NOI18N
        lblAvatarfyea.setText("fyea");

        lblAvatarpface.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/pictures/chalenge.jpg"))); // NOI18N

        lblAvatarmegusta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/pictures/megusta.png"))); // NOI18N
        lblAvatarmegusta.setText("megusta");

        lblAvatarkiddingme.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/pictures/kiddingme.jpg"))); // NOI18N
        lblAvatarkiddingme.setText("fkiddingme");

        lblAvatartruestrory.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/pictures/true_story.png"))); // NOI18N
        lblAvatartruestrory.setText("truestory");

        lblAvatarTroll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/pictures/troll.png"))); // NOI18N
        lblAvatarTroll.setText("troll");

        rbgAvatar.add(rbFyea);
        rbFyea.setText("F yea");

        rbgAvatar.add(rbmegusta);
        rbmegusta.setText("Me gusta");

        rbgAvatar.add(rbfkidding);
        rbfkidding.setText("Are you f kidding me?");

        rbgAvatar.add(rbchallenge);
        rbchallenge.setText("Challenge accepted");

        rbgAvatar.add(rbTrueStory);
        rbTrueStory.setText("True story");

        rbgAvatar.add(rbTrollFace);
        rbTrollFace.setText("Troll face");

        btnNext2.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        btnNext2.setText(">>");
        btnNext2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNext2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelAvatarLayout = new javax.swing.GroupLayout(panelAvatar);
        panelAvatar.setLayout(panelAvatarLayout);
        panelAvatarLayout.setHorizontalGroup(
            panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAvatarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelAvatarLayout.createSequentialGroup()
                        .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelAvatarLayout.createSequentialGroup()
                                    .addComponent(lblAvatarpface, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                                    .addGap(38, 38, 38))
                                .addGroup(panelAvatarLayout.createSequentialGroup()
                                    .addComponent(rbchallenge)
                                    .addGap(45, 45, 45)))
                            .addComponent(lblAvatarfyea, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rbFyea))
                        .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblAvatartruestrory, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rbTrueStory)
                            .addGroup(panelAvatarLayout.createSequentialGroup()
                                .addGap(8, 8, 8)
                                .addComponent(rbmegusta))
                            .addComponent(lblAvatarmegusta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(49, 49, 49)
                        .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblAvatarkiddingme, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rbTrollFace)
                            .addComponent(lblAvatarTroll, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rbfkidding))
                        .addContainerGap(14, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelAvatarLayout.createSequentialGroup()
                        .addComponent(btnNext2)
                        .addContainerGap())))
        );
        panelAvatarLayout.setVerticalGroup(
            panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelAvatarLayout.createSequentialGroup()
                .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblAvatarfyea, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                    .addComponent(lblAvatarmegusta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAvatarkiddingme, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbFyea)
                    .addComponent(rbmegusta)
                    .addComponent(rbfkidding))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAvatarpface, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAvatartruestrory, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAvatarTroll, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelAvatarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(rbchallenge)
                        .addComponent(rbTrueStory)
                        .addComponent(rbTrollFace))
                    .addComponent(btnNext2))
                .addContainerGap())
        );

        PanelRegistrationCool.addTab("Avatar", panelAvatar);

        jLabel2.setText("Izaberite 3 oblasti o kojima želite da postavljate statuse i dobijate obavestenje: ");

        btnSave.setText("Sačuvaj");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelAreasLayout = new javax.swing.GroupLayout(panelAreas);
        panelAreas.setLayout(panelAreasLayout);
        panelAreasLayout.setHorizontalGroup(
            panelAreasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAreasLayout.createSequentialGroup()
                .addGroup(panelAreasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelAreasLayout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(jLabel2))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelAreasLayout.createSequentialGroup()
                        .addGap(185, 185, 185)
                        .addGroup(panelAreasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbSecondArea, 0, 241, Short.MAX_VALUE)
                            .addComponent(cbFirstArea, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbThirdArea, 0, 241, Short.MAX_VALUE))))
                .addContainerGap(47, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelAreasLayout.createSequentialGroup()
                .addContainerGap(392, Short.MAX_VALUE)
                .addComponent(btnSave)
                .addContainerGap())
        );
        panelAreasLayout.setVerticalGroup(
            panelAreasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAreasLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(cbFirstArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cbSecondArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cbThirdArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 75, Short.MAX_VALUE)
                .addComponent(btnSave)
                .addContainerGap())
        );

        PanelRegistrationCool.addTab("OblastiInteresovanja", panelAreas);

        rbgDefaultUserProfile.add(rbTrendyName);
        rbTrendyName.setText("Trendi korisnički profil");

        rbgDefaultUserProfile.add(rbSeriousName);
        rbSeriousName.setText("Zašto tako ozbiljno?");

        lblUDTrendyImage.setText("trd");

        lblUDWSSImage.setText("wss");

        jScrollPane1.setViewportView(listAreasOfInterestTrendy);

        jScrollPane2.setViewportView(listAreasOfInterestSerious);

        btnSaveDefaulProfileUser.setText("Sačuvaj");
        btnSaveDefaulProfileUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveDefaulProfileUserActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelDefaultUserProfileLayout = new javax.swing.GroupLayout(panelDefaultUserProfile);
        panelDefaultUserProfile.setLayout(panelDefaultUserProfileLayout);
        panelDefaultUserProfileLayout.setHorizontalGroup(
            panelDefaultUserProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDefaultUserProfileLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDefaultUserProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDefaultUserProfileLayout.createSequentialGroup()
                        .addComponent(rbTrendyName)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(lblUDTrendyImage, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelDefaultUserProfileLayout.createSequentialGroup()
                        .addComponent(rbSeriousName)
                        .addGap(12, 12, 12)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(lblUDWSSImage, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnSaveDefaulProfileUser, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        panelDefaultUserProfileLayout.setVerticalGroup(
            panelDefaultUserProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDefaultUserProfileLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblUDTrendyImage, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lblUDWSSImage, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(btnSaveDefaulProfileUser)
                .addContainerGap())
            .addGroup(panelDefaultUserProfileLayout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addGroup(panelDefaultUserProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rbTrendyName)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                .addGroup(panelDefaultUserProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rbSeriousName))
                .addGap(41, 41, 41))
        );

        PanelRegistrationCool.addTab("Predefinisani korisnički profili", panelDefaultUserProfile);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PanelRegistrationCool, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PanelRegistrationCool)
        );
    }// </editor-fold>//GEN-END:initComponents

private void btnNext1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNext1ActionPerformed
    String value = JOptionPane.showInputDialog(this, "Želite li da izaberete predefinisani korisnički profil(1) ili da sami kreirate svoj profil(2)?", "Način kreiranja vašeg tipa profila.", JOptionPane.QUESTION_MESSAGE);
    if (value.equals("1")) {
        PanelRegistrationCool.setEnabledAt(0, false);
        PanelRegistrationCool.setEnabledAt(1, false);
        PanelRegistrationCool.setEnabledAt(2, false);
        PanelRegistrationCool.setEnabledAt(3, true);
        TrendyUserProfile tup = new TrendyUserProfile();
        WhySoSeriousUserProfile wss = new WhySoSeriousUserProfile();
        lblUDTrendyImage.setIcon(tup.createAvatar().getAvatarImg());
        lblUDWSSImage.setIcon(wss.createAvatar().getAvatarImg());
        rbTrendyName.setText(TrendyUserProfile.class.getSimpleName());
        rbSeriousName.setText(WhySoSeriousUserProfile.class.getSimpleName());
        listAreasOfInterestSerious.setListData(wss.createAreasOfInterest().toArray());
        listAreasOfInterestTrendy.setListData(tup.createAreasOfInterest().toArray());
        PanelRegistrationCool.setSelectedComponent(panelDefaultUserProfile);

    } else {
        rbFyea.setText("F yea");
        rbTrollFace.setText("Troll face");
        rbchallenge.setText("Challenge accepted");
        rbfkidding.setText("Are you f kidding me?");
        rbmegusta.setText("Me gusta");
        rbTrueStory.setText("True story");
        PanelRegistrationCool.setEnabledAt(0, false);
        PanelRegistrationCool.setEnabledAt(1, true);
        PanelRegistrationCool.setEnabledAt(2, false);
        PanelRegistrationCool.setEnabledAt(3, false);
        PanelRegistrationCool.setSelectedComponent(panelAvatar);

    }
}//GEN-LAST:event_btnNext1ActionPerformed

private void btnNext2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNext2ActionPerformed
    PanelRegistrationCool.setSelectedComponent(panelAreas);
    PanelRegistrationCool.setEnabledAt(0, false);
    PanelRegistrationCool.setEnabledAt(1, false);
    PanelRegistrationCool.setEnabledAt(2, true);
    PanelRegistrationCool.setEnabledAt(3, false);
}//GEN-LAST:event_btnNext2ActionPerformed

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
    try {
        String username = tfUserName.getText().trim();
        String password = tfPassword.getText().trim();
        String firstName = tfFirstName.getText().trim();
        String lastName = tfLastName.getText().trim();
        // char sex=GetPol.getPol(String.valueOf(rbgPol.getSelection()));
        char sex = 'a';
        for (Enumeration e = rbgPol.getElements(); e.hasMoreElements();) {
            JRadioButton b = (JRadioButton) e.nextElement();
            if (b.getModel() == rbgPol.getSelection()) {
                String selectedSex = b.getText();
                if (selectedSex != null && selectedSex.equalsIgnoreCase("Muški")) {
                    sex = 'm';
                } else if (selectedSex != null && selectedSex.equalsIgnoreCase("Ženski")) {
                    sex = 'z';
                }
            }
        }
        //JOptionPane.showMessageDialog(this, sex);

        String email = tfEmail.getText().trim();
        String avatar = "";
        for (Enumeration e = rbgAvatar.getElements(); e.hasMoreElements();) {
            JRadioButton b = (JRadioButton) e.nextElement();
            if (b.getModel() == rbgAvatar.getSelection()) {
                String selectedAvatar = b.getText();
                if (selectedAvatar != null && selectedAvatar.equalsIgnoreCase("F yea")) {
                    avatar = "F yea";
                } else if (selectedAvatar != null && selectedAvatar.equalsIgnoreCase("Troll face")) {
                    avatar = "Troll face";
                } else if (selectedAvatar != null && selectedAvatar.equalsIgnoreCase("Challenge accepted")) {
                    avatar = "Challenge accepted";
                } else if (selectedAvatar != null && selectedAvatar.equalsIgnoreCase("Are you f kidding me?")) {
                    avatar = "Are you f kidding me?";
                } else if (selectedAvatar != null && selectedAvatar.equalsIgnoreCase("Me gusta")) {
                    avatar = "Me gusta";
                } else if (selectedAvatar != null && selectedAvatar.equalsIgnoreCase("True story")) {
                    avatar = "True story";
                }
            }
        }
        //JOptionPane.showMessageDialog(this, avatar);
        String aoi1 = String.valueOf(cbFirstArea.getSelectedItem());
        String aoi2 = String.valueOf(cbSecondArea.getSelectedItem());
        String aoi3 = String.valueOf(cbThirdArea.getSelectedItem());

        FormCoordinator.getInstance().saveNewFPUser(username, password, firstName, lastName, sex, email, avatar, aoi1, aoi2, aoi3);
        JOptionPane.showMessageDialog(this, "Uspešna registracija!");
        FormCoordinator.getInstance().setNewPanel(new PanelHome());
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage());
        Logger.getLogger(PanelRegistration.class.getName()).log(Level.SEVERE, null, ex);
    }

}//GEN-LAST:event_btnSaveActionPerformed

private void tfUserNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfUserNameFocusLost
    try {
        FormCoordinator.getInstance().checkAvailability(tfUserName.getText().trim());
        tfUserName.setBorder(new LineBorder(Color.GREEN));
        lblUsnError.setVisible(false);
        lblUsnError.setText("Korisničko ime je raspoloživo");
    } catch (Exception ex) {
        tfUserName.setBorder(new LineBorder(Color.RED));
        lblUsnError.setVisible(true);
        lblUsnError.setText(ex.getMessage());
    }
}//GEN-LAST:event_tfUserNameFocusLost

private void btnSaveDefaulProfileUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveDefaulProfileUserActionPerformed
    try {
        String username = tfUserName.getText().trim();
        String password = tfPassword.getText().trim();
        String firstName = tfFirstName.getText().trim();
        String lastName = tfLastName.getText().trim();
        char sex = 'a'; //GetPol.getPol(String.valueOf(rbgPol.getSelection()));
        for (Enumeration e = rbgPol.getElements(); e.hasMoreElements();) {
            JRadioButton b = (JRadioButton) e.nextElement();
            if (b.getModel() == rbgPol.getSelection()) {
                String selectedSex = b.getText();
                if (selectedSex != null && selectedSex.equalsIgnoreCase("Muški")) {
                    sex = 'm';
                } else if (selectedSex != null && selectedSex.equalsIgnoreCase("Ženski")) {
                    sex = 'z';
                }
            }
        }

        String email = tfEmail.getText().trim();
        String defaultProfileName = ""; //String.valueOf(rbgDefaultUserProfile.getSelection());
                for (Enumeration e = rbgDefaultUserProfile.getElements(); e.hasMoreElements();) {
            JRadioButton b = (JRadioButton) e.nextElement();
            if (b.getModel() == rbgDefaultUserProfile.getSelection()) {
                String selectedUserProfile = b.getText();
                if (selectedUserProfile != null && selectedUserProfile.equalsIgnoreCase(TrendyUserProfile.class.getSimpleName())) {
                    defaultProfileName = TrendyUserProfile.class.getSimpleName();
                } else if (selectedUserProfile != null && selectedUserProfile.equalsIgnoreCase(WhySoSeriousUserProfile.class.getSimpleName())) {
                    defaultProfileName = WhySoSeriousUserProfile.class.getSimpleName();
                }
            }
        }

        JOptionPane.showMessageDialog(this, defaultProfileName);

        FormCoordinator.getInstance().saveNewFPUser(username, password, firstName, lastName, sex, email, defaultProfileName);
        JOptionPane.showMessageDialog(this, "Uspešna registracija!");
        FormCoordinator.getInstance().setNewPanel(new PanelHome());
    }   catch (Exception ex) {
            Logger.getLogger(PanelRegistration.class.getName()).log(Level.SEVERE, null, ex);
        } 
}//GEN-LAST:event_btnSaveDefaulProfileUserActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane PanelRegistrationCool;
    private javax.swing.JButton btnNext1;
    private javax.swing.JButton btnNext2;
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnSaveDefaulProfileUser;
    private javax.swing.JComboBox cbFirstArea;
    private javax.swing.JComboBox cbSecondArea;
    private javax.swing.JComboBox cbThirdArea;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblAvatarTroll;
    private javax.swing.JLabel lblAvatarfyea;
    private javax.swing.JLabel lblAvatarkiddingme;
    private javax.swing.JLabel lblAvatarmegusta;
    private javax.swing.JLabel lblAvatarpface;
    private javax.swing.JLabel lblAvatartruestrory;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblFirstName;
    private javax.swing.JLabel lblLastName;
    private javax.swing.JLabel lblPassword;
    private javax.swing.JLabel lblPol;
    private javax.swing.JLabel lblUDTrendyImage;
    private javax.swing.JLabel lblUDWSSImage;
    private javax.swing.JLabel lblUserName;
    private javax.swing.JLabel lblUsnError;
    private javax.swing.JList listAreasOfInterestSerious;
    private javax.swing.JList listAreasOfInterestTrendy;
    private javax.swing.JPanel panelAreas;
    private javax.swing.JPanel panelAvatar;
    private javax.swing.JPanel panelDefaultUserProfile;
    private javax.swing.JPanel panelUserInformation;
    private javax.swing.JRadioButton rbFemail;
    private javax.swing.JRadioButton rbFyea;
    private javax.swing.JRadioButton rbMale;
    private javax.swing.JRadioButton rbSeriousName;
    private javax.swing.JRadioButton rbTrendyName;
    private javax.swing.JRadioButton rbTrollFace;
    private javax.swing.JRadioButton rbTrueStory;
    private javax.swing.JRadioButton rbchallenge;
    private javax.swing.JRadioButton rbfkidding;
    private javax.swing.ButtonGroup rbgAvatar;
    private javax.swing.ButtonGroup rbgDefaultUserProfile;
    private javax.swing.ButtonGroup rbgPol;
    private javax.swing.JRadioButton rbmegusta;
    private javax.swing.JTextField tfEmail;
    private javax.swing.JTextField tfFirstName;
    private javax.swing.JTextField tfLastName;
    private javax.swing.JTextField tfPassword;
    private javax.swing.JTextField tfUserName;
    // End of variables declaration//GEN-END:variables
}
